<extend name="Public/base" />

<block name="body">
    <form method="POST" id="form1" action="">
        <!-- 标题栏 -->
        <div class="main-title">
            <h2>
                {$title}
                <!--<a onclick="export1();" class="btn confirm btn-default">数据导出</a>-->
            </h2>
        </div>
        
        <div class="navbar navbar-default" style="margin: 0px;">
         
            <!-- 高级搜索 -->
            <div class="search-form " style="margin-top: 10px;margin-left: 10px;">
                <div class="sleft">
                   日期：
                   <input type="text" name="startDate" class="text input-large time" value="{$startDate}" placeholder="请选择统计日期"   style="height: 30px;width:200px" />
                   到：
                   <input type="text" name="endDate" class="text input-large time" value="{$endDate}" placeholder="请选择统计日期"   style="height: 30px;width:120px" />
                </div>
                <div class="sleft">
                    <a class="sch-btn" href="javascript:;" id="search" url="{:U('')}"><i class="btn-search"></i></a>
                </div>
            </div>
           
            
        </div>
        <div class="data-table table-striped">
            <canvas id="myChart"  height="400" style="width: 100%;height: 400px;"></canvas>
        </div>
        <!-- 数据列表 -->
        <div class="data-table table-striped">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th width="15%">日期</th>
                        <th width="10%">损耗量</th>
                        <th width="15%">统计图</th>

                    </tr>
                </thead>
                <tbody>
                <notempty name="_list">
                    <volist name="_list" id="vo">
                        <tr>
                            <td>{$vo.lossDate}</td>
                            <td>{$vo.losscnt}</td>
                            <td>
                                <a href="{:U('dailyproductdetail')}&day={$vo.lossDate}" class="btn btn-danger">商品信息</a>
                                <a href="{:U('dailydetail')}&day={$vo.lossDate}" class="btn btn-success">报损原因</a>
                                <a href="{:U('dailyclassdetail')}&day={$vo.lossDate}" class="btn btn-primary">报损状态</a>
                            </td>
                        </tr>
                    </volist>
                    <else/>
                    <td colspan="12" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
            </table>
        </div>
        <div class="page">
            {$_page}
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/Chart/Chart.min.js"></script>

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');

            var query = $('.search-form').find('input').serialize();
            var queryselect = $('.search-form').find('select').serialize();

            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            queryselect = queryselect.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            queryselect = queryselect.replace(/^&/g, '');

            if (url.indexOf('?') > 0) {
                url += '&' + query;
                url += '&' + queryselect;
            } else {
                url += '?' + query;
                url += '?' + queryselect;
            }

            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        highlight_subnav('{:U('Loss/lossdaily')}');
        
        $(function () {
            $('.time').datetimepicker({
                format: 'Y-m-d H:i:s',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });
        });
        
        function export1(){
            var url = "{:U('Report/dailyExport')}";
            $("#form1").attr("action", url).submit();
        }
        
        
        var data = {
                labels : {$dayDataArr},
                datasets : [
                    {
                        fillColor : "rgba(151,187,205,0.5)",
                        strokeColor : "rgba(151,187,205,1)",
                        pointColor : "rgba(151,187,205,1)",
                        pointStrokeColor : "#fff",
                        data : {$lossDataArr}
                    }
                ]
             }
        var ctx = document.getElementById("myChart").getContext("2d");
        var myNewChart = new Chart(ctx).Line(data);
    </script>
</block>
